using System;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;

namespace Granite.Wcf.Debugging
{
	/// <summary>
	/// Use this for examining how the interface works.
	/// </summary>
	public class DebugEndpointBehavior : DebugAttribute, IEndpointBehavior
	{
		/// <summary>
		/// Implement to pass data at runtime to bindings to support custom behavior.
		/// </summary>
		/// <param name="endpoint">
		/// The endpoint to modify.
		/// </param>
		/// <param name="bindingParameters">
		/// The objects that binding elements require to support the behavior.
		/// </param>
		public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
		{
			WriteLine(string.Format("IEndpointBehavior.AddBindingParameters: endpoint=\"{0}\", bindingParameters.Count={1}", endpoint.Name, bindingParameters.Count));
		}

		/// <summary>
		/// Implements a modification or extension of the client across an endpoint.
		/// </summary>
		/// <param name="endpoint">
		/// The endpoint that is to be customized.
		/// </param>
		/// <param name="clientRuntime">
		/// The client runtime to be customized.
		/// </param>
		public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
		{
			WriteLine(string.Format("IEndpointBehavior.ApplyClientBehavior: endpoint=\"{0}\", clientRuntime.ContractName={1}", endpoint.Name, clientRuntime.ContractName));
		}

		/// <summary>
		/// Implements a modification or extension of the service across an endpoint.
		/// </summary>
		/// <param name="endpoint">
		/// The endpoint that exposes the contract.
		/// </param>
		/// <param name="endpointDispatcher">
		/// The endpoint dispatcher to be modified or extended.
		/// </param>
		public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
		{
			WriteLine(string.Format("IEndpointBehavior.ApplyDispatchBehavior: endpoint=\"{0}\"", endpoint.Name));
		}

		/// <summary>
		/// Implement to confirm that the endpoint meets some intended criteria.
		/// </summary>
		/// <param name="endpoint">
		/// The endpoint to validate.
		/// </param>
		public void Validate(ServiceEndpoint endpoint)
		{
			WriteLine(string.Format("IEndpointBehavior.Validate: endpoint=\"{0}\"", endpoint.Name));
		}

	}
}
